#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
#include<string.h>

void Reverse(char* start, char* end)
{
	int tmp = 0;
	int k = end - start;
	while (start < end)
	{
		tmp = *start;
		*start = *end;
		*end = tmp;
		start++, end--;
	}
}

int main()
{
	char ch[100] = { 0 };
	scanf("%s", ch);
	int len = strlen(ch);
	int time = 0;
	scanf("%d", &time);
	time %= len;
	Reverse(ch, ch + time - 1);
	Reverse(ch + time, ch + len - 1);
	Reverse(ch, ch + len - 1);
	printf("%s", ch);
	return 0;
}



//#include<stdio.h>
//
//void test(int* p)
//{
//	p++;
//}
//
//int main()
//{
//	int arr[10] = { 1,2,3,4,5,6,7,8,9,10 };
//	test(arr);
//	printf("%d", arr[0]);
//	return 0;
//}